<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../../include.inc.jsp"%>
<div class="row">
    <div class="col-lg-12">
        <form id="formDlg" class="form-horizontal" role="form">
            <input type="hidden" id="id" name="id" value="${department.id}" />
            <!-- 数据权限 -->
            <input type="hidden" id="organizationId" name="organization.id" value="${organizationId}" />
            <div class="form-group">
                <label class="col-lg-2 control-label">所属医院:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="hidden" class="form-control" id="hospitalId" name="hospital.id" value="${department.hospital.id}" />
                    <input type="text" readonly="readonly" class="form-control" id="hospitalName" name="hospitalName" value="${department.hospital.name}" onclick="selectHospital();"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">科室名称:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="name" name="name" value="${department.name}" maxlength="30"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">科室编码:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="code" name="code" value="${department.code}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">TV智能卡:</label><span class="text-danger">*</span>
                <div class="col-lg-9">
                    <input type="text" class="form-control" id="cardNo" name="cardNo" value="${department.cardNo}" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-lg-2 control-label">科室介绍:</label>
                <div class="col-lg-9">
                    <textarea class="form-control" id="remark" name="remark">${department.remark}</textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
function selectHospital(){
	var ajaxSelectUrl = contextPath + '/manage/ordering/hospital/select';
	showSelectDlg("选择医院",ajaxSelectUrl,["table-data1"],setSelectValue);
}
function setSelectValue(obj){
	$("#hospitalId").val(obj[0].id);
	$("#hospitalName").val(obj[0].name);
}
jQuery(function($) {
    $('#formDlg').validate({
        errorElement : 'span',
        errorClass : 'help-block',
        focusCleanup : false,
        focusInvalid : false,
        onsubmit : false,
        rules : {
            "name":{required:true},
            "code":{required:true},
            "cardNo":{required:true},
            "hospitalName":{required:true},
        },
        messages : {
            "name" : '请输入科室名称',
            "code" : '请输入科室编码',
            "cardNo" : '请输入TV智能卡',
            "hospitalName" : '请选择所属医院',
        },
        highlight : function(e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
        },
        success : function(e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(e).remove();
        },
    });
});
</script>